#pragma once

class DetourVariant;

class Stream
{
public:
	virtual ~Stream(){ }

	virtual void Write(const void *ptr, int length) = 0;
	virtual int Read(void *buf, int buflength) = 0;
	virtual void Flush() = 0;
	virtual void Close() = 0;
};

class ValueStream : public Stream
{
public:



	virtual void Write(char chVal) = 0;
	virtual void Write(long lVal) = 0;
	virtual void Write(unsigned short usVal) = 0;
	virtual void Write(int intVal) = 0;
	virtual void Write(const wchar_t *str) = 0;
	virtual void Write(const char *str) = 0;

	
	virtual char ReadChar() = 0;
	virtual long ReadLong() = 0;
	virtual unsigned short ReadUShort() = 0;
	virtual int ReadInt() = 0;
	virtual std::wstring ReadWString() = 0;
	virtual std::string ReadString() = 0;



	virtual void WriteOne(const DetourVariant *var) = 0;
	virtual void WriteAll(const DetourVariant *var) = 0;

	virtual void ReadOne(DetourVariant *var) = 0;
	virtual DetourVariant* ReadAll() = 0;


};


class CFileEx;
class FileStream : public Stream
{
public:
	FileStream(LPCTSTR pszFileName, bool write);
	virtual ~FileStream();
	virtual void Flush();
	virtual void Close();
	virtual void Write(const void *ptr, int length);
	virtual int Read(void *buf, int buflength);
public:
	CFileEx *m_pFile;
};

class BinaryStream : public ValueStream
{
public:

	BinaryStream(Stream *pStrm);
	virtual ~BinaryStream();

	virtual void Write(const void *ptr, int length);
	virtual int Read(void *buf, int buflength);
	virtual void Flush();
	virtual void Close();

	virtual void Write(char chVal);
	virtual void Write(long lVal);
	virtual void Write(unsigned short usVal);
	virtual void Write(int intVal);
	virtual void Write(const wchar_t *str);
	virtual void Write(const char *str);


	virtual char ReadChar();
	virtual long ReadLong();
	virtual unsigned short ReadUShort();
	virtual int ReadInt();
	virtual std::wstring ReadWString();
	virtual std::string ReadString();


	virtual void WriteOne(const DetourVariant *var);
	virtual void WriteAll(const DetourVariant *var);

	virtual void ReadOne(DetourVariant *var);
	virtual DetourVariant* ReadAll();

private:
	Stream *m_pStrm;
};